// Upgrade NOTE: commented out 'float4x4 _Object2World', a built-in variable
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'


Shader  "Custom/HeightFogNoAO" {

	Properties
	 {
 _MainTex ("Texture 1", 2D) = "white" {}
 _FogColour ("fog colour", Color) = (1,1,1,1)
 _LightColour0 ("Light colour 0", Color) = (1,0.73,0.117,0)
 _LightColour1 ("Light colour 1", Color) = (0.05,0.275,0.275,0)
 _LightColour2 ("Light colour 2", Color) = (0,0,0,0)
 _LightColour3 ("Rim colour", Color) = (0,0,0,0)
 _LightTint ("Light Multiplier", Color) = (1,1,1,0)
 _AmbientColour1 ("Light Add", Color) = (0.5,0.5,0.5,0)
 _Density ("Fog Density", Float) = 0.1
 _Plane ("_Plane", Vector) = (0,1,0,1)
}

	

	SubShader
     {
  Tags { "LIGHTMODE"="ForwardBase" "QUEUE"="Geometry" "RenderType"="Opaque" }

    LOD 100
	Pass
	{
	
	

	CGPROGRAM
	#pragma vertex vert
	#pragma fragment frag
	#include "UnityCG.cginc"
    #define Fixed3(value)  fixed3(value, value,value)
    #define Fixed4(value)  fixed4(value, value,value,value)

	struct VertexInput {
    fixed4 vertex : POSITION;
	fixed2 xlv_TEXCOORD0 : TEXCOORD0;
    //fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
    //fixed4 tangent : TANGENT;
    fixed3 normal : NORMAL;
    //fixed4 xlv_COLOR : COLOR;
	//VertexInput
	};


	struct VertexOutput {
	fixed4 pos : SV_POSITION;
    UNITY_FOG_COORDS(1)
    //fixed4 xlv_COLOR : COLOR;
	fixed2 xlv_TEXCOORD0 : TEXCOORD0;
    //fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    fixed xlv_TEXCOORD3 : TEXCOORD3;
    fixed2 xlv_TEXCOORD4 : TEXCOORD4;
	//VertexOutput
	};

	

 
 
 
 
 // float4x4 _Object2World;
 float4 _LightColour0;
 float4 _LightColour1;
 float4 _LightColour2;
 float4 _LightColour3;
 float4 _AmbientColour1;
 float _Density;
 float4 _Plane;


	

 sampler2D _MainTex;
 float4 _LightTint;
 float4 _FogColour;




	VertexOutput vert (VertexInput v)
	{
	VertexOutput o;
	//o.pos = UnityObjectToClipPos (v.vertex);
	//o.xlv_TEXCOORD0 = TRANSFORM_TEX(v.xlv_TEXCOORD0, _MainTex);
	
  float2 tmpvar_1;
  tmpvar_1 = v.xlv_TEXCOORD0;
  float3 flatWorldNormal_2;
  float2 tmpvar_3=float2(0,0);
  float4 tmpvar_4;
  tmpvar_4 = UnityObjectToClipPos( v.vertex);
  float4 tmpvar_5;
  tmpvar_5 = mul(unity_ObjectToWorld , v.vertex);
  float4 tmpvar_6;
  tmpvar_6.w = 0.0;
  tmpvar_6.xyz = normalize(v.normal);
  float3 tmpvar_7;
  tmpvar_7 = normalize(mul(unity_ObjectToWorld , tmpvar_6).xyz);
  flatWorldNormal_2.xy = tmpvar_7.xy;
  flatWorldNormal_2.z = 0.0;
  float tmpvar_8;
  tmpvar_8 = sqrt(dot (flatWorldNormal_2, flatWorldNormal_2));
  if ((tmpvar_8 > 0.0001)) {
    flatWorldNormal_2 = normalize(flatWorldNormal_2);
  };
  float tmpvar_9;
  tmpvar_9 = clamp (-(flatWorldNormal_2).x, -1.0, 1.0);
  float tmpvar_10;
  tmpvar_10 = ((1.5708 - (
    sign(tmpvar_9)
   * 
    (1.5708 - (sqrt((1.0 - 
      abs(tmpvar_9)
    )) * (1.5708 + (
      abs(tmpvar_9)
     * 
      (-0.214602 + (abs(tmpvar_9) * (0.0865667 + (
        abs(tmpvar_9)
       * -0.0310296))))
    ))))
  )) / 1.5708);
  float tmpvar_11;
  tmpvar_11 = clamp (-(tmpvar_7).z, -1.0, 1.0);
  float tmpvar_12;
  tmpvar_12 = (1.0 - ((1.5708 - 
    (sign(tmpvar_11) * (1.5708 - (sqrt(
      (1.0 - abs(tmpvar_11))
    ) * (1.5708 + 
      (abs(tmpvar_11) * (-0.214602 + (abs(tmpvar_11) * (0.0865667 + 
        (abs(tmpvar_11) * -0.0310296)
      ))))
    ))))
  ) / 1.5708));
  o.pos = tmpvar_4;
  o.xlv_TEXCOORD0 = tmpvar_1;
  o.xlv_TEXCOORD2 = (lerp (lerp (
    lerp (_LightColour0.xyz, _LightColour3.xyz, Fixed3(fixed((flatWorldNormal_2.x >= 0.0))))
  , 
    lerp (_LightColour1.xyz, _LightColour3.xyz, Fixed3(fixed((0.0 >= flatWorldNormal_2.y))))
  , Fixed3(
    lerp (tmpvar_10, (2.0 - tmpvar_10), fixed((flatWorldNormal_2.x >= 0.0)))
  )), lerp (_LightColour2.xyz, _LightColour3.xyz, Fixed3(
    fixed((0.0 >= -(tmpvar_7.z)))
  )), Fixed3(lerp (tmpvar_12,
    -(tmpvar_12)
  , 
    fixed((0.0 >= tmpvar_12))
  ))) + _AmbientColour1.xyz);
  o.xlv_TEXCOORD3 = ((dot (tmpvar_5.xyz, _Plane.xyz) - _Plane.w) * _Density);
  o.xlv_TEXCOORD4 = tmpvar_3;


    UNITY_TRANSFER_FOG(o,o.vertex);
   
	return o;
	}


	fixed4 frag(VertexOutput i) : SV_Target
    {
    //fixed4 tmpvar_2 = tex2D(_MainTex, i.uv);
	
  half4 tmpvar_1;
  float4 main_color_2;
  main_color_2.w = 0.0;
  fixed4 tmpvar_3;
  tmpvar_3 = tex2D (_MainTex, i.xlv_TEXCOORD0);
	UNITY_APPLY_FOG(i.fogCoord, tmpvar_3);
  main_color_2.xyz = ((_LightTint.xyz * i.xlv_TEXCOORD2) * tmpvar_3.xyz);
  main_color_2.xyz = lerp (main_color_2, _FogColour, Fixed4(clamp (clamp (i.xlv_TEXCOORD3, 0.0, 1.0), 0.0, 1.0))).xyz;
  main_color_2.w = 1.0;
  tmpvar_1 = main_color_2;
  return tmpvar_1;

	}
	ENDCG
	}
  }
Fallback "Diffuse"
}

